<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			.menu{
				display: flex;
			}
			.menu>*{
				width: 100px;
				height: 70px;
				background-color: aqua;
				border: 1px solid black;
			}
			.menu-show{
				background-color: red;
				display: block;
			}
			.menu-hide{
				display: none;
			}
			.menu-show>.menu-hide{
				display: block;
			}
			.menu-show>.menu-hide>:first-child{
				margin-top: 100%;
			}
		</style>
	</head>
	<body>
		<div class="menu">
			<div class="app"></div>
			<div>
				<div class="menu menu-hide">
					<div>
					</div>
					<div>1</div>
					<div>1</div>
				</div>
			</div>
			<div></div>
		</div>
		<script>
			var data={}
			init()
			Object.defineProperties(data,{
				"menuLength":{
					get(){
						return data._menuLength
					},
					set:function(menuLength) {
						if(this.menuLength!=menuLength){
							console.log(this)
							data._menuLength=menuLength
							init()
						}
					}
				}
			})
			data.menuLength=document.getElementsByClassName('menu').length
			
			function init(){
				Array.from(document.getElementsByClassName('menu')).forEach(submenu=>{
					var timer;
					console.log(document.getElementsByClassName('menu').length)
					data.menuLength=2
					if(true){
						submenu.onmouseenter=function(){
						clearTimeout(timer)
						this.onclick=function(){
							var clas=event.target.classList
							if(!Array.from(clas).includes('menu-show')){
								clas.add('menu-show')
							}else{
								clas.remove('menu-show')
							}
						}
						this.onmouseleave=function(){
							var that=this
							timer=setTimeout(()=>{
								Array.from(that.getElementsByClassName('menu-show')).forEach(clas=>{
									var clas=clas.classList
									if(Array.from(clas).includes('menu-show')){
										clas.remove("menu-show")
									}
								})
							},3000)
						}
					}
					}
				})
			}
		</script>
	</body>
</html>